package net.guruqu.rvoView;

import com.jme.math.Vector2f;
import com.jme.scene.Node;
import com.jme.scene.SharedNode;
import com.jme.scene.Spatial;

public class SceneAgent extends Node {
	private Vector2f position;
	private float groundLevel;

	public SceneAgent(int id) {
		super("Scene Agent #" + id);
		if (ModelRepository.get() == null)
			throw new RuntimeException("No model repository in context");

		position = new Vector2f();
		groundLevel = 0;

		{
			Spatial agentSp =  (Spatial) ModelRepository.get().getRepository().get(
			"agent");
			Node agentModel = null;
			if(agentSp instanceof Node){
				agentModel=(Node)agentSp;
			}else{
				agentModel = new Node("Agent Model Raw#"+id);
				agentModel.attachChild(agentSp);
			}
			SharedNode agentNode = new SharedNode("Agent model#" + id,
					agentModel);
			attachChild(agentNode);
		}
		updateModelBound();
	}

	public Vector2f getPosition() {
		return position;
	}

	public void setPosition(float x, float y) {
		this.position.set(x, y);
		setLocalTranslation(x, groundLevel, y);
	}

	public float getGroundLevel() {
		return groundLevel;
	}

	public void setGroundLevel(float groundLevel) {
		this.groundLevel = groundLevel;
	}
}
